package com.ryan.demo.grpc.server.provider;


import com.ryan.demo.grpc.api.AckReceiptData;
import com.ryan.demo.grpc.api.SendAckData;
import com.ryan.demo.grpc.api.SubAckHubGrpc;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * @author MRyan
 */
@Slf4j
@Service
public class SubAckHubGrpcServiceImpl extends SubAckHubGrpc.SubAckHubImplBase {

    @Override
    public void sendAck(SendAckData request, StreamObserver<AckReceiptData> responseObserver) {
        log.info("Start sendAck");

        AckReceiptData receiptRes = AckReceiptData.newBuilder()
                .setClientIp("101.200.183.85")
                .setSuccess(true)
                .build();

        responseObserver.onNext(receiptRes);
        responseObserver.onCompleted();
    }
}
